﻿public class Singleton<T> where T : new()
{
    private static T __instance;
    private static readonly object __lock = new object();
    public static T GetInstance()
    {
        if (__instance == null)
        {
            lock (__lock)
            {
                if (__instance == null)
                    __instance = new T();
            }
        }        
        return __instance;
    }
}
